package com.wwj.code.config.handlerInterceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author admin007
 * 自定义拦截器
 */
@Slf4j
//@Component
public class MyHandlerInterceptor implements HandlerInterceptor {
    /**
     * 视图渲染之后的操作
     */
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object obj, Exception e) {
        log.info("afterCompletion： 请问我该做点什么，请求指示  333333");
    }

    /**
     * 处理请求完成后视图渲染之前的处理操作
     */
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object obj, ModelAndView modelAndView) {
        log.info("postHandle： 注意，我处理请求完成视图渲染了，请求下一步指示  2222222");

    }

    /**
     * 进入controller层之前拦截请求
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) {
        log.info("preHandle： 注意，敌人要进来了，我要不要拦截  1111111111");

        return true;
    }
}